Alembic setup#579
Conversation
|
Nice setup overall — the initial migration, the round-trip tests, and the CI check are all solid. A few things I think are worth addressing before merge: init_db.py runs both create_all() and migrations. Right now
Small one in env.py: One note on the tests: they run against in-memory SQLite, which is great for verifying up/down/round-trip mechanics. Just worth keeping in mind that since the app runs on Postgres, migrations using Postgres-specific types (JSONB, etc. — which the #544 models will use) won't be exercised by these. Not a blocker for this PR, just relevant for what comes next. Happy to re-review once you've had a look. |
| Create Date: 2026-06-22 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union |
There was a problem hiding this comment.
The modern alternative to Python's typing.Union is the | (pipe) operator, introduced via PEP 604.
| Create Date: 2026-06-22 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union |
There was a problem hiding this comment.
Same for sequence. If you are using typing.Sequence for type hinting, the modern alternative is to use collections.abc.Sequence or the built-in list generic. Python has moved away from the bulky typing module. Modern Python allows you to use builtin collections directly with subscripts (like list[int]) and union types.
We are adding more models soon (#544) and the current
create_all()approach can only create tables, not alter them. This PR sets up Alembic so we can track and apply schema changes going forward.Changes
alembictorequirements.txtalembic.ini,alembic/env.py, andalembic/script.py.mako001_initial_schema.py) that captures the existingTemplateandFormSubmissiontablesapp/db/init_db.pyto runalembic upgrade headinstead ofcreate_all()create_all()with in-memory SQLite for speedalembic checkstep in CI to catch missing migrationsmake migrateandmake migrationcommandsPart of #541
Fix: #578